﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using S1882I;

namespace card
{
    public partial class FrmMenu : Form
    {
        public static WebDG.Service ws = new card.WebDG.Service();
        DataSet ds;
        S1882IReWr rw = new S1882IReWr();
        //private string role;
        public string role
        {
            get;
            set;
        }
        //private string cardadd;
        public string cardadd
        {
            get;
            set;
        }
        public string io_port
        {
            get;
            set;
        }
        public string card_if
        {
            get;
            set;
        }

        string str_operator = "";
        public FrmMenu()
        {
            InitializeComponent();
        }

        private void btn_car_in_Click(object sender, EventArgs e)
        {
            STCHDJForm frm1 = new STCHDJForm();
            frm1.Text = "市提车货登记-" + Session.Operator_User.ToString();
            frm1.Show();
        }

        private void FrmMenu_Load(object sender, EventArgs e)
        {
            //Get the shippers for SRCHDJ Form
            //string sqlStr = "select SHIPPER_NAME,SHIPPER_BRIEF from V_SHIPPER_DOC_TCC";
            //ds = ws.getDataSet_Serv(sqlStr);

            //connect_card();
            card_if = "0";
            str_operator = this.Text.Substring(6);
            if (role == "市提")
            {
                btn_car_card.Enabled = true;
                btn_car_in.Enabled = true;
                //btn_noplan_car.Enabled = true;

                //btn_noplan_cargo.Enabled = false;
                btn_cargo_card.Enabled = false;
                btn_cargo_in.Enabled = false;
            }
            if (role == "市入")
            {
                btn_car_card.Enabled = false;
                btn_car_in.Enabled = false;
                //btn_noplan_car.Enabled = false;

                //btn_noplan_cargo.Enabled = true;
                btn_cargo_card.Enabled = true;
                btn_cargo_in.Enabled = true;
            }
            if (role == "全部")
            {
                btn_car_card.Enabled = true;
                btn_car_in.Enabled = true;
                //btn_noplan_car.Enabled = true;

                //btn_noplan_cargo.Enabled = true;
                btn_cargo_card.Enabled = true;
                btn_cargo_in.Enabled = true;
            }
        }

        private void btn_cargo_in_Click(object sender, EventArgs e)
        {
            SRCHDJForm frm1 = new SRCHDJForm();
            frm1.Text = "市入车货登记-" + Session.Operator_User.ToString();
            //*************************************//
            ////lgc注销，没有数据。无作用
            //frm1.shippers = ds;
            //***********************************//
            frm1.Show();
        }

        private void btn_car_card_Click(object sender, EventArgs e)
        {
            ////this.Hide();

            ////Frm_car_card frm1 = new Frm_car_card();//
            //STXXFK frm1 = new STXXFK();
            //frm1.Text = "市提信息反馈-" + Session.Operator_User.ToString();
            ////frm1.cardadd = cardadd;
            ////frm1.io_port = io_port;
            //frm1.Show();
        }

        private void btn_cargo_card_Click(object sender, EventArgs e)
        {
            ////this.Hide();

            ////Frm_cargo_card frm1 = new Frm_cargo_card();
            //SRXXFK frm1 = new SRXXFK();
            //frm1.Text = "市入信息反馈-" + Session.Operator_User.ToString();
            ////frm1.cardadd = cardadd;
            ////frm1.io_port = io_port;
            //frm1.Show();
        }

        private void btn_noplan_car_Click(object sender, EventArgs e)
        {
            //this.Hide();

            Frm_noplan_car frm1 = new Frm_noplan_car();
            frm1.Text = "无计划市提车辆登记" + str_operator;
            frm1.cardadd = cardadd;
            frm1.io_port = io_port;
            frm1.Show();
        }

        private void btn_noplan_cargo_Click(object sender, EventArgs e)
        {
            //this.Hide();

            Frm_noplan_cargo frm1 = new Frm_noplan_cargo();
            frm1.Text = "无计划市入车辆登记" + str_operator;
            frm1.cardadd = cardadd;
            frm1.io_port = io_port;
            frm1.Show();
        }

        private void btn_exit_Click(object sender, EventArgs e)
        {
            //disconnect_card();
            Application.Exit();
        }

        private void btn_total_Click(object sender, EventArgs e)
        {
            FrmCount frm1 = new FrmCount();
            frm1.Text = "统计-" + str_operator;
            frm1.cardadd = cardadd;
            frm1.Show();
        }

        private void connect_card()
        {
            short by = rw.Connect_Open(io_port);
            if (by == 0)
            { }
            //MessageBox.Show (DateTime.Now + "  提示:连接读写器成功.\r\n");
            else
            {
                MessageBox.Show(DateTime.Now + String.Format("  错误:读写器连接失败:{0:X}.", by) + "\r\n");
            }
            //rtLog.ScrollToCaret(); 
        }
        private void disconnect_card()
        {
            short by = rw.Connect_Close();
            if (by == 0)
            { }
            //  rtLog.AppendText(DateTime.Now + "  提示:读写器断开成功.\r\n");
            else
            {
                MessageBox.Show(DateTime.Now + String.Format("  错误:读写器连接断开失败:{0:X}.", by) + "\r\n");
            }

            //rtLog.ScrollToCaret(); 
        }

        private void btn_cancelcard_Click(object sender, EventArgs e)
        {
            //this.Hide();
            Frm_cancelFrom frm1 = new Frm_cancelFrom();
            //Frm_cancellogin frm1 = new Frm_cancellogin();
            frm1.Text = "取消登记-" + str_operator;
            frm1.str_operator = str_operator;
            frm1.cardadd = cardadd;
            if (Session.Role == "市提")
            {
                frm1.ioyardid = "0";
            }
            if (Session.Role == "市入")
            {
                frm1.ioyardid = "1";
            }
            if (Session.Role == "全部")
            {
                frm1.ioyardid = "9";
            }
            frm1.Show();
        }

        private void btn_readcard_Click(object sender, EventArgs e)
        {
            //this.Hide();

            Frm_readcard frm1 = new Frm_readcard();
            frm1.Text = "读卡" + str_operator;
            frm1.io_port = io_port;
            frm1.Show();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Frm_color frm1 = new Frm_color();
            frm1.Show();
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            CustomerComboBoxTest frm1 = new CustomerComboBoxTest();
            frm1.Show();
        }
        //点击右上角的关闭按钮关闭窗口的时候退出应用
        private void FrmMenu_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            XPLISTForm frm1 = new XPLISTForm();

            frm1.Show();
        }

        private void button3_Click(object sender, EventArgs e)
        {

        }

        private void button5_Click(object sender, EventArgs e)
        {

        }

        private void button4_Click(object sender, EventArgs e)
        {

        }
    }
}
